package ArrayList;
/*
* 按照{元素#元素#元素}的格式打印集合
* */

import java.util.ArrayList;

public class ArrayList3 {
    public static void main(String[] args) {
        ArrayList<String> list = new ArrayList<>();
        list.add("张三");
        list.add("李四");
        list.add("狗五");
        System.out.println(list);

        printArraylist(list);
    }

    public static void printArraylist(ArrayList<String> list){
        System.out.print("{");
        for (int i = 0; i < list.size(); i++) {
            String name = list.get(i);
            if(i == list.size() - 1 ){
                System.out.print(name + "}");
            }else{
                System.out.print(name + "@");
            }
        }
    }
}
